module AdminApi
  module AdminConfig
    class Admin
      @@routes = nil
      @@config = nil
      @@inheritance_class= nil
      class << self
        def register _class, &block
          @@inheritance_class = Class.new AdminApi::BaseAdminController
          Object.const_set "AdminAPI#{_class.name}sController", @@inheritance_class
          yield self
          #save_routes
        end
        def controller &block
          #define new route
          yield @@inheritance_class
        end
        def save_routes
          @@inheritance_class.methods.each do
          #Will be configuered later for the rest of the application
          puts methods.to_s
        end
        end
        def routes rails_routes
          #Define routes to our controller
          print rails_routes.methods
          return @@routes
        end
        def config
          yield(self.config)
        end
        private
          def complete_serializer serializer
            @@inheritance_class.complete_serializer = serializer
          end
          def short_serializer serializer
            @@inheritance_class.short_serializer = serializer
          end
          def permit_params *attributes
            @@inheritance_class.permit_params = *attributes
          end
        end
      end
  end
end
